﻿@{
    ViewBag.Title = "Index";
}

@section scripts{
    <script type="text/javascript">
        $(f_init);
        var grid = null, dialog = null;

        function f_init() {
            grid = $("#maingrid").ligerGrid({
                url: '@Url.Content("~/System/GetUserGridData/")',
                columns: [
                    { name: 'UserName', display: '用户名' },
                    { name: 'CreateUserID', display: '加入时间', type: 'date' }
                ],
                sortName: 'UserID',
                height: '100%',
                heightDiff: -40
            });

            $("#toolbar").ligerToolBar({
                items:[
                    { text: '增加', icon: 'add', click: addUser },
                    { text: '修改', icon: 'edit', click: editUser},
                    { text: '删除', icon: 'delete', click: delUser }
                ]
            });
        }
        function addUser() {
            dialog = $.ligerDialog.open({
                height: 600,
                width: 800,
                title: '新增用户信息',
                url: '@Url.Content("~/System/UserDetail/")',
                showMax: false,
                showToggle: true,
                showMin: false,
                isResize: true,
                slide: false,
                data: {
                    callback: function () {
                        grid.reload();
                        dialog.close();
                    }
                } 
            }); 
        }
        function editUser() {
            var selected = grid.getSelected();
            if(selected == null) {
                $.ligerDialog.error("请选择行");
                return;
            }
            dialog = $.ligerDialog.open({
                height: 600,
                width: 800,
                title: '编辑/查看用户信息',
                url: '@Url.Content("~/System/UserDetail/?id=")' + selected.UserID,
                showMax: false,
                showToggle: true,
                showMin: false,
                isResize: true,
                slide: false,
                data: {
                    callback: function () {
                        grid.reload();
                        dialog.close();
                    }
                } 
            }); 
        }
        function delUser() {
           
        }
    </script> 
    <style type="text/css">
        .l-toolbar {
            background:none;
            height: 32px;
            border: 1px solid #D3d3d3; background:#f3f2f2;
        }

    </style>
}
 
<div id="toolbar" style="margin:8px;margin-bottom:1px;"></div>

<div id="maingrid" style="margin:8px;"></div>
